package com.easilyj.service.impl;

import com.easilyj.bean.Article;
import com.easilyj.dao.ArticleDao;
import com.easilyj.service.ArticleService;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@CacheConfig(cacheNames = "article")
public class ArticleServiceImpl implements ArticleService {

    @Resource
    private ArticleDao articleDao;

    @Override
    public Article getOne(Long id) {
        return articleDao.getOne(id);
    }

    @Override
    public void delete(Long id) {
        articleDao.deleteById(id);
    }

    @Override
    public Article save(Article article) {
        return articleDao.save(article);
    }

    @Override
    public List<Article> findAllByArticleTypeId(Long id) {
        return articleDao.findAllByArticleTypeId(id);
    }
}

